<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Simple Super Mario</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/matter-js/0.18.0/matter.min.js"></script>
    <style>
        body {
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: #87CEEB;
            font-family: 'Arial', sans-serif;
        }

        canvas {
            border: 3px solid #333;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
        }

        #score {
            font-size: 24px;
            margin-bottom: 10px;
            color: #333;
        }

        #game-over {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: rgba(255, 255, 255, 0.9);
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            display: none;
            z-index: 10;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
        }

        #restart-btn {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            margin-top: 10px;
        }

        #restart-btn:hover {
            background-color: #45a049;
        }

        /* 移动端控制按钮样式 */
        #mobile-controls {
            display: flex;
            justify-content: center;
            margin-top: 20px;
            width: 100%;
            max-width: 800px;
            padding: 0 10px;
        }

        .control-btn {
            width: 80px;
            height: 80px;
            margin-right: 30px;
            background-color: rgba(255, 255, 255, 0.8);
            border: 2px solid #333;
            border-radius: 50%;
            font-size: 28px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
        }

        .control-btn:active {
            background-color: rgba(200, 200, 200, 0.9);
        }

        #jump-btn {
            margin-left: auto;
            margin-right: 0;
        }

        @media (max-width: 768px) {
            canvas {
                width: 100%;
                max-width: 500px;
                height: auto;
            }
        }
    </style>
</head>

<body>
    <div id="score">分数: 0</div>
    <canvas id="gameCanvas" width="800" height="500"></canvas>

    <div id="mobile-controls">
        <div class="control-btn" id="left-btn">←</div>
        <div class="control-btn" id="right-btn">→</div>
        <div class="control-btn" id="jump-btn">↑</div>
    </div>

    <div id="game-over">
        <h2>游戏结束！</h2>
        <p>最终得分: <span id="final-score">0</span></p>
        <button id="restart-btn">重新开始</button>
    </div>

    <!-- 使用ES模块导入 -->
    <script type="module">
        import { initGame } from './js/game.js';
        
        // 页面加载完成后启动游戏
        window.addEventListener('DOMContentLoaded', () => {
            initGame();
        });
    </script>
</body>
</html>